package com.mh.controller;

import com.mh.dto.R;
import com.mh.dto.vo.GoodsDataReturnDto;
import com.mh.dto.vo.GoodsDataVo;
import com.mh.dto.vo.GoodsTipsVo;
import com.mh.pojo.GoodsInfos;
import com.mh.service.GoodsInfosService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Date:2024/10/20
 * author:zmh
 * description: 商品信息相关接口
 **/

@RestController
@RequestMapping("goodsInfos")
@CrossOrigin
@Slf4j
@RequiredArgsConstructor
public class GoodsInfosController {

    private final GoodsInfosService goodsInfosService;

    /**
     * 商品列表视图组件获取商品数据
     * @param goodsDataVo 封装商品列表组件请求参数对象
     * @return `
     */
    @PostMapping("/getGoodsData")
    public R<GoodsDataReturnDto> getGoodsData(@RequestBody GoodsDataVo goodsDataVo) {
        return goodsInfosService.getGoodsData(goodsDataVo);
    }

    /**
     * 根据商品名称获取商品信息（模糊搜索 - 搜索提示）
     * @param goodsName 商品名称
     * @return ·
     */
    @GetMapping("/getGoodsInfosByName/{goodsName}")
    public R<List<GoodsInfos>> getGoodsInfosByName(@PathVariable String goodsName) {
        return goodsInfosService.getGoodsInfosByName(goodsName);
    }

    /**
     * 根据商品id获取商品信息
     * @param goodsId 商品id
     * @return ·
     */
    @GetMapping("/getGoodsInfosById/{goodsId}")
    public R<GoodsInfos> getGoodsInfosById(@PathVariable String goodsId) {
        return goodsInfosService.getGoodsInfosById(goodsId);
    }

}





